import { Badge } from "../../module/common/BadgeType";
import { IKey } from "../common/Common";
import { Fview } from "../gui/UIDefine";
import Pool from "../pool/Pool";

export class BadgeView {

    private types = new Set<IKey>();

    /**监听的UI */
    view: Fview;

    //标识，方便批量移除
    caller: any;

    static create(): BadgeView {
        return Pool.get(BadgeView);
    }

    add(v: IKey) {
        this.types.add(v);
    }

    remove(v: IKey) {
        this.types.delete(v);
    }

    has(v: IKey) {
        return this.types.has(v);
    }

    isEmpty() {
        return this.types.size <= 0;
    }

    get array() {
        return Array.from(this.types);
    }

    recover() {
        this.caller = this.view = null;
        this.types.clear();
        Pool.put(this);
    }
}